#coding:utf-8

import httplib
import urllib

HOST = "smartcard.sinaapp.com"
PORT=80
METHOD="POST"
REQUEST_URL = "/topic/17/post"

def http_request(context):
    #请求参数
    params = urllib.urlencode({'author': '老郭', 'email': 'laoguo@126.com', 'url':'http://laoguo.com', 'con':context, 'postid': '17', 'act': 'submit'})
    print params
    #请求头
    headers={
    "Content-type":"application/x-www-form-urlencoded",
    "Accept":"text/plain",
    }
    conn=httplib.HTTPConnection(HOST,PORT)
    conn.request(METHOD,REQUEST_URL,params,headers)
    response=conn.getresponse()
    data=response.read()
    conn.close()
    return (response.status,response.reason,data)

if __name__=="__main__":

    for i in range(0x10):
        s = "这是十六进制的第0x%08X条" %(i)
        print s
        status,result,data=http_request(s)
        print type(status), type(result), type(data)
        print status,result
    #print data

